package com.chen.pojo;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

//博客实体类
public class Article {

    private Integer article_id; //主键
    private Date  article_data; //发布日期
    private User user;  //发布者

    private String article_title;//文章标题
    private Integer like_count;//点赞数
    private Integer comment_count;//评论数
    private Integer read_count;//阅读数
    private String top_flag;  //是否置顶
    private String article_summary;//文章摘要

    private String content_html;//文章内容保存

    private String article_picture; //文章封面

    private String article_description;//文章描述


    public Article() {
    }

    public Article(Integer article_id, Date article_data, String article_title, Integer like_count, Integer comment_count,
                   Integer read_count, String top_flag, String article_summary,
                   String content_html, String article_picture,
                   String article_description) {
        this.article_id = article_id;
        this.article_data = article_data;
        this.article_title = article_title;
        this.like_count = like_count;
        this.comment_count = comment_count;
        this.read_count = read_count;
        this.top_flag = top_flag;
        this.article_summary = article_summary;
        this.content_html = content_html;
        this.article_picture = article_picture;
        this.article_description = article_description;
    }



    /*public Article(Integer article_id, Date article_data, User userId, String article_title, Integer like_count, Integer comment_count, Integer read_count, String top_flag, String article_summary, String content_html) {
        this.article_id = article_id;
        this.article_data = article_data;
        this.user= userId;
        this.article_title = article_title;
        this.like_count = like_count;
        this.comment_count = comment_count;
        this.read_count = read_count;
        this.top_flag = top_flag;
        this.article_summary = article_summary;
        this.content_html = content_html;
    }*/

    public String getContent_html() {
        return content_html;
    }

    public void setContent_html(String content_html) {
        this.content_html = content_html;
    }

    public Integer getArticle_id() {
        return article_id;
    }

    public void setArticle_id(Integer article_id) {
        this.article_id = article_id;
    }

    public Date getArticle_data() {
        return article_data;
    }

    public void setArticle_data(Date article_data) {

        //时间转化。数据库CST 时间格式转 Date
        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sim.format(article_data);
        Date newDate=null;
        try {
            newDate = sim.parse(format);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        assert newDate != null;
        java.sql.Date resultDate = new java.sql.Date(newDate.getTime());
        this.article_data = resultDate;
    }

    public User getUserId() {
        return user;
    }

    public void setUserId(User userId) {
        this.user = userId;
    }

    public String getArticle_title() {
        return article_title;
    }

    public void setArticle_title(String article_title) {
        this.article_title = article_title;
    }

    public Integer getLike_count() {
        return like_count;
    }

    public void setLike_count(Integer like_count) {
        this.like_count = like_count;
    }

    public Integer getComment_count() {
        return comment_count;
    }

    public void setComment_count(Integer comment_count) {
        this.comment_count = comment_count;
    }

    public Integer getRead_count() {
        return read_count;
    }

    public void setRead_count(Integer read_count) {
        this.read_count = read_count;
    }

    public String getTop_flag() {
        return top_flag;
    }

    public void setTop_flag(String top_flag) {
        this.top_flag = top_flag;
    }

    public String getArticle_summary() {
        return article_summary;
    }

    public void setArticle_summary(String article_summary) {
        this.article_summary = article_summary;
    }

    public String getArticle_picture() {
        return article_picture;
    }

    public String getArticle_description() {
        return article_description;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setArticle_picture(String article_picture) {
        this.article_picture = article_picture;
    }

    public void setArticle_description(String article_description) {
        this.article_description = article_description;
    }

    @Override
    public String toString() {
        return "Article{" +
                "article_id=" + article_id +
                ", article_data=" + article_data +
                ", user=" + user +
                ", article_title='" + article_title + '\'' +
                ", like_count=" + like_count +
                ", comment_count=" + comment_count +
                ", read_count=" + read_count +
                ", top_flag='" + top_flag + '\'' +
                ", article_summary='" + article_summary + '\'' +
                ", content_html='" + content_html + '\'' +
                ", article_picture='" + article_picture + '\'' +
                ", article_description='" + article_description + '\'' +
                '}';
    }
}
